package com.guragura.widget;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.guragura.Guragura;
import com.guragura.screens.GameScreen;
import com.guragura.screens.MainMenuScreen;
import com.guragura.util.Constants;

public class PauseDialog extends Dialog {

	private Image background;
	private Button resumeButton;
	private Button restartButton;
	private Button helpButton;
	private Button optionsButton;
	private Button exitButton;

	public Guragura guragura;

	public PauseDialog(float width, float height, Guragura guragura) {
		super(width, height);
		this.guragura = guragura;

		resumeButton = new Button(guragura.atlasInterface.findRegion(
				Constants.RESUME_BUTTON, 1),
				guragura.atlasInterface.findRegion(Constants.RESUME_BUTTON, 2));
		restartButton = new Button(guragura.atlasInterface.findRegion(
				Constants.RESTART_BUTTON, 1),
				guragura.atlasInterface.findRegion(Constants.RESTART_BUTTON, 2));
		helpButton = new Button(guragura.atlasInterface.findRegion(
				Constants.HELP_BUTTON, 1), guragura.atlasInterface.findRegion(
				Constants.HELP_BUTTON, 2));
		optionsButton = new Button(guragura.atlasInterface.findRegion(
				Constants.OPTION_BUTTON, 1),
				guragura.atlasInterface.findRegion(Constants.OPTION_BUTTON, 2));
		exitButton = new Button(guragura.atlasInterface.findRegion(
				Constants.EXIT_BUTTON, 1), guragura.atlasInterface.findRegion(
				Constants.EXIT_BUTTON, 2));

		background = new Image(
				guragura.atlasInterface.findRegion(Constants.PAUSE_SCREEN));

		resumeButton.setClickListener(new ClickListener() {

			@Override
			public void click(Actor arg0, float arg1, float arg2) {
				// TODO Auto-generated method stub				
				((GameScreen) getGura().gameScreen).resumeGame();
			}
		});

		restartButton.setClickListener(new ClickListener() {

			@Override
			public void click(Actor arg0, float arg1, float arg2) {
				// TODO Auto-generated method stub
				((GameScreen) getGura().gameScreen).restartGame();

			}
		});

		helpButton.setClickListener(new ClickListener() {

			@Override
			public void click(Actor arg0, float arg1, float arg2) {
				// TODO Auto-generated method stub
				getGura().showHelp();
			}
		});

		optionsButton.setClickListener(new ClickListener() {

			@Override
			public void click(Actor arg0, float arg1, float arg2) {
				// TODO Auto-generated method stub
				getGura().showSetting();
			}
		});
		exitButton.setClickListener(new ClickListener() {

			@Override
			public void click(Actor arg0, float arg1, float arg2) {
				((GameScreen) getGura().gameScreen).exitScreen();
			}
		});

		
		exitButton.x = (320 - exitButton.width) / 2;
		optionsButton.x = (320 - optionsButton.width) / 2;
		helpButton.x = (320 - helpButton.width) / 2;
		restartButton.x = (320 - restartButton.width) / 2;
		resumeButton.x = (320 - resumeButton.width) / 2;
		
		exitButton.y = (480 - exitButton.height * 5)/2;
		optionsButton.y = exitButton.y + exitButton.height;
		helpButton.y = optionsButton.y + optionsButton.height;
		restartButton.y = helpButton.y + helpButton.height;
		resumeButton.y = restartButton.y + restartButton.height;
		
		
		addActor(background);
		addActor(exitButton);		
		addActor(optionsButton);
		addActor(helpButton);
		addActor(restartButton);
		addActor(resumeButton);
		
	}

	
	
	public Guragura getGura() {
		return guragura;
	}

	public PauseDialog getSelf() {
		return this;
	}

}
